<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class S_Config extends CI_Config {

	/*
	 * 支持子目录绑定域名^_^，在config/domain.php中设置
	 */
	public function site_url($uri = '')
	{
		$uri = trim($uri, '/');
		
		if ($uri)
		{
			$uri = explode('/', $uri);
			$this->load('domain', TRUE, TRUE);
			$domain = $this->item('domain');
			if ($domain && ($key = array_search($uri[0], $domain)))
			{
				array_shift($uri);
				$base_url = rtrim($key, '/').str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
			}
		}
		
		if ( ! isset($base_url))
		{
			$base_url = $this->slash_item('base_url');
		}

		return $base_url.$this->item('index_page').'/'.implode('/', $uri);
	}

}